{include file="Public:header" /}
{include file="Public:nav" /}
<div class="bar bar-nav">
			<h1 class="title">修改活动</h1>
			<i class="icon icon-left" onclick="window.history.go(-1);"></i>
		</div>
		<div class="content">
		<form action="{:U('Users/editActivity')}" method="post" id="activity_form" class="sui-form form-horizontal" enctype="multipart/form-data">
			<div class="row activity_banner">
				<div class="col-100 publish_sc">
					<img id="img" src="{$data['activity_img']}" height="220px">
					<button class="button button-fill ">上传活动海报</button>
					<input type="file" name="activity_img" id="photo">
				</div>
			</div>

			<div class="row activity_list publish_list">
				<div class="col-100">
					<div class="list-block">
						
						<ul class="input-daterange">
							<li class="item-content">
								<div class="item-media"><i class="iconfont icon-discount"></i></div>
								<div class="item-inner">
									<div class="item-input"><input type="text" name="activity_name" placeholder="活动主题" value="{$data['activity_name']}" /></div>
								</div>
							</li>
							<li class="item-content">
								<div class="item-media"><i class="iconfont icon-clock"></i></div>
								<div class="item-inner">
									<div class="item-input"><input type="text" name="start_time" class="input-medium-1 input-date" placeholder="活动开始时间" value="{$data['start_time']|date="Y-m-d H:i",###}" /></div>
								</div>
							</li>
							<li class="item-content">
								<div class="item-media"><i class="iconfont icon-history"></i></div>
								<div class="item-inner">
									<div class="item-input"><input type="text" name="end_time" class="input-medium-2 input-date" placeholder="活动结束时间" value="{$data['end_time']|date="Y-m-d H:i",###}" /></div>
								</div>
							</li>
							<li class="item-content">
								<div class="item-media"><i class="iconfont icon-zhubanfang"></i></div>
								<div class="item-inner">
									<div class="item-input">
										<input type="text" name="sponsor" placeholder="主办方" value="{$data['sponsor']}" />
									</div>
								</div>
							</li>
							<li class="item-content">
								<div class="item-media"><i class="iconfont icon-category"></i></div>
								<div class="item-inner">
									<div class="item-input">
										<select name="category">
											<option value="">选择分类</option>
										  {foreach name="category" item="v" key="k" }
										  	<option {if condition="$v['id'] eq $data['category']"}selected{/if} value="{$v['id']}">{$v['name']}</option>
										  {/foreach}
										</select>
									</div>
								</div>
							</li>
							<li class="item-content">
								<div class="item-media"><i class="iconfont icon-map"></i></div>
								<div class="item-inner">
									<div class="item-input">
										<input class="input_map" name="address" type="text" placeholder="活动地点" value="{$data['province']} {$data['city']} {$data['area']}" />
									</div>
								</div>
							</li>
							<li class="item-content">
								<div class="item-media"><i class="iconfont icon-map"></i></div>
								<div class="item-inner">
									<div class="item-input">
										<input type="text" name="detail_address" placeholder="详细地址" value="{$data['detail_address']}" />
									</div>
								</div>
							</li>
							<li class="item-content">
								<div class="item-media"><i class="iconfont icon-renshu"></i></div>
								<div class="item-inner">
									<div class="item-input">
										<input type="text" name="number" placeholder="人数限制" value="{$data['number']}" />
									</div>
								</div>
							</li>
							<li class="item-content">
								<div class="item-media"><i class="iconfont icon-phone"></i></div>
								<div class="item-inner">
									<div class="item-input">
										<input type="text" name="contact_mobile" placeholder="联系方式" value="{$data['contact_mobile']}" />
									</div>
								</div>
							</li>
							<li class="item-content">
								<div class="item-media"><i class="iconfont icon-demo22"></i></div>
								<div class="item-inner">
									<div class="item-input">
										<input type="text" name="price" placeholder="报名费用，免费请0" value="{$data['price']}" >
									</div>
								</div>
							</li>
							<!-- <li class="item-content">
								<div class="item-inner">
									<div class="item-input">
										<a href="{:U('Users/show_page')}"> 
											<textarea  rows="4" placeholder="活动简介"></textarea>
										</a>
										<input type="hidden" name="describe" value=""/>
										
									</div>
								</div>
							</li> -->
						</ul>
						<div class="publish_bottom">
						<input type="hidden" name="activity_id" value="{$activity_id}" />
								<label><input name="agree" checked type="checkbox">我同意《发布活动协议》</label>
								<button type="submit" style="width: 100%;margin-top: 1rem;" class="create-actions button-block button button-fill">下一步</button>
						</div>
						
					</div>
				</div>
			</div>
			</form>
</div>

{include file="Public:footer" /}


<script type="text/javascript">
 $("#photo").change(function(){
      var objUrl = getObjectURL(this.files[0]);
      console.log("objUrl = "+objUrl);
      if (objUrl) {
          $("#img").attr("src", objUrl);
      }
  }) ;
 //建立一個可存取到該file的url
 function getObjectURL(file) {
     var url = null ;
     if (window.createObjectURL!=undefined) { // basic
         url = window.createObjectURL(file) ;
     } else if (window.URL!=undefined) { // mozilla(firefox)
         url = window.URL.createObjectURL(file) ;
     } else if (window.webkitURL!=undefined) { // webkit or chrome
         url = window.webkitURL.createObjectURL(file) ;
     }
     return url ;
 }
 
 $("#activity_form").submit(function(){
	/*  if($("input[name='activity_img']").val() == ''){
		 Zepto.toast('请上传活动海报！', 2000, 'success top');
		 return false;
	 } */
	 if($("input[name='activity_name']").val() == ''){
		 Zepto.toast('请填写活动主题！', 2000, 'success top');
		 return false;
	 }
	 if($("input[name='start_time']").val() == ''){
		 Zepto.toast('请选择开始时间！', 2000, 'success top');
		 return false;
	 }
	 if($("input[name='end_time']").val() == ''){
		 Zepto.toast('请选择结束时间！', 2000, 'success top');
		 return false;
	 }
	 if($("input[name='sponsor']").val() == ''){
		 Zepto.toast('请填写主办方！', 2000, 'success top');
		 return false;
	 }
	 if($("select[name='category']").val() == ''){
		 Zepto.toast('请填写分类！', 2000, 'success top');
		 return false;
	 }
	 if($("input[name='address']").val() == ''){
		 Zepto.toast('请填写活动地点！', 2000, 'success top');
		 return false;
	 }
	 if($("input[name='detail_address']").val() == ''){
		 Zepto.toast('请填写详细地址！', 2000, 'success top');
		 return false;
	 }
	 if($("input[name='number']").val() == ''){
		 Zepto.toast('请填写人数限制！', 2000, 'success top');
		 return false;
	 }
	 if($("input[name='contact_mobile']").val() == ''){
		 Zepto.toast('请填写联系方式！', 2000, 'success top');
		 return false;
	 }
	 var myreg = /(1[3-9]\d{9})$/;
	 if(!myreg.test($("input[name='contact_mobile']").val())){
		 Zepto.toast('手机格式不对！', 2000, 'success top');
		 return false;
	 }
	 if($("input[name='price']").val() == ''){
		 Zepto.toast('请填写报名费用！', 2000, 'success top');
		 return false;
	 }
	 if($("input[name='agree']").is(':checked') == false){
		 Zepto.toast('请勾选协议！', 2000, 'success top');
		 return false;
	 }
	 
 });
</script>
		<!--城市选择结束-->
		<script type="text/javascript" src="http://g.alicdn.com/msui/sm/0.6.2/js/sm-city-picker.min.js" charset="utf-8"></script>
		<script>
			Zepto(function(){
				Zepto(".input-medium-1").datetimePicker({
    			//value: ['2017', '01', '01', '9',"00"],
  				});
  				Zepto(".input-medium-2").datetimePicker({
    			//value: ['2017', '01', '01', '9',"00"],
  				});
  				Zepto(".input_map").cityPicker({
				    toolbarTemplate: '<header class="bar bar-nav">\
				    <button class="button button-link pull-right close-picker">确定</button>\
				    <h1 class="title">选择活动地点</h1>\
				    </header>'
				});
			})
		</script>
